package net.wanho.shop.config;

import net.wanho.shop.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 拦截器配置
 */
@Configuration
public class AuthConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 添加拦截器
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/captchaImage", "/login", "/captchaLogin", "/logout", "/file/upload", "/smsCode", "/smsLogin")
                // 放行knife4j
                .excludePathPatterns("/doc.html", "/webjars/**", "/v2/**", "/swagger-resources/**");

    }
}
